package com.ec.rs.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.ec.common.exception.BadRequestException;
import lombok.Getter;

@Getter
public enum BedStatus {
    VACANT("vacant", "空闲"),
    OCCUPIED("occupied", "占用");

    @EnumValue
    private final String value;
    private final String desc;

    BedStatus(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static BedStatus of(String value) {
        if ("vacant".equals(value)) {
            return VACANT;
        }
        if ("occupied".equals(value)) {
            return OCCUPIED;
        }
        throw new BadRequestException("床位状态错误");
    }
}